/**
  ******************************************************************************
  * @file    gd32f20cl_eval_exmc_sdram.h
  * @author  MCU SD
  * @version V1.0.0
  * @date    15-Jul-2015
  * @brief   The header file of the read and write sdram.
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __EXMC_SDRAM_H
#define __EXMC_SDRAM_H

/* Includes ------------------------------------------------------------------*/
#include "gd32f20x_exmc.h"

/* Exported define -----------------------------------------------------------*/
/* Define mode register content */
/* Burst Length */
#define SDRAM_MODEREG_BURST_LENGTH_1             ((uint16_t)0x0000)
#define SDRAM_MODEREG_BURST_LENGTH_2             ((uint16_t)0x0001)
#define SDRAM_MODEREG_BURST_LENGTH_4             ((uint16_t)0x0002)
#define SDRAM_MODEREG_BURST_LENGTH_8             ((uint16_t)0x0003)

/* Burst Type */
#define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL      ((uint16_t)0x0000)
#define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED     ((uint16_t)0x0008)

/* CAS Latency */
#define SDRAM_MODEREG_CAS_LATENCY_2              ((uint16_t)0x0020)
#define SDRAM_MODEREG_CAS_LATENCY_3              ((uint16_t)0x0030)

/* Write Mode */
#define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000)
#define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE     ((uint16_t)0x0200)

#define SDRAM_MODEREG_OPERATING_MODE_STANDARD    ((uint16_t)0x0000)

/* Exported functions --------------------------------------------------------*/
void SDRAM_Init(uint32_t EXMC_Bank);
void SDRAM_WriteBuffer_8(uint32_t EXMC_Bank,uint8_t* pBuffer, uint32_t WriteAddr, uint32_t NumByteToWrite);
void SDRAM_ReadBuffer_8(uint32_t EXMC_Bank,uint8_t* pBuffer, uint32_t ReadAddr, uint32_t NumByteToRead);
void SDRAM_WriteBuffer_16(uint32_t EXMC_Bank,uint16_t* pBuffer, uint32_t WriteAddr, uint32_t NumHalfwordToWrite);
void SDRAM_ReadBuffer_16(uint32_t EXMC_Bank,uint16_t* pBuffer, uint32_t ReadAddr, uint32_t NumHalfwordToRead);
void SDRAM_WriteBuffer_32(uint32_t EXMC_Bank,uint32_t* pBuffer, uint32_t WriteAddr, uint32_t NumWordToWrite);
void SDRAM_ReadBuffer_32(uint32_t EXMC_Bank,uint32_t* pBuffer, uint32_t ReadAddr, uint32_t NumWordToRead);

#endif  /* __EXMC_SDRAM_H */

/******************* (C) COPYRIGHT 2015 GIGADEVICE *****END OF FILE****/
